home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util4 / 0utils.lha / 0Utils / CAR.data < prev    next >
Text File  |  1995-09-05  |  2KB  |  85 lines

  1.  
  2. #ifdef TPLTER
  3.  
  4. CAR = {
  5.  
  6.     NoParsing;
  7.  
  8.     Version = "1.1";
  9.     Short = {{ Get the first in a list of Words }};
  10.  
  11.     description = {{
  12.     Get the first word in a list of Words
  13.  
  14.     CAR and CDR build a pair that is in most cases
  15.     used together.
  16.     }};
  17.     Notes = {{
  18.     We currently do ignore ReadArgs, so do not expext
  19.     "CAR ?" to work.
  20.     }};
  21.  
  22.     Template = "/A/F";
  23.     Arguments = {{
  24.     STRPTR line;
  25. #    undef CDR
  26.     }};
  27.  
  28.  
  29.     History = {{
  30.     16-04-95 b_noll (1.0) created
  31.     19-08-95 b_noll created .data file
  32.     19-08-95 b_noll (1.1) added newline output to CAR branch
  33.     }};
  34.     Body = {{
  35.     STRPTR sline, rline, line;
  36.     line = GetArgStr();
  37.     if (line) {
  38.         sline = rline = line;
  39.         while (*line == ' ') line++;
  40.         if (*line && (*line != '\n')) {
  41.         UBYTE buffer[MAXLINELEN];
  42.  
  43.         if (*line == '"') {
  44.             /* ---- closing quote */
  45.             ++line;
  46.             while (*line && (*line != '"'))
  47.             if (*(line++) == '*')
  48.                 if (*line)
  49.                 line++;
  50.         } else {
  51.             /* ---- end of first word */
  52.             while (*line && (*line != ' '))
  53.             line++;
  54.         } /* if */
  55.  
  56. #        if $(@isequal@CDR@$(CMD))
  57.             /* ---- Start of next word */
  58.             while (*line && (*line == ' '))
  59.             line++;
  60.  
  61.             PutStr ((*line) ? line : "\n");
  62.             retval = *line ? RETURN_OK : RETURN_WARN;
  63. #        else
  64.         {
  65.             UBYTE ch;
  66.             ch       = *line;
  67.             *line  = 0;
  68.             PutStr (sline);
  69.             PutStr ("\n");
  70.             *line  = ch;
  71.             retval = ch ? RETURN_OK : RETURN_WARN;
  72.         }
  73. #        endif
  74.         } else {
  75.         retval = RETURN_ERROR;
  76.         SetIoErr(ERROR_REQUIRED_ARG_MISSING);
  77.         } /* if */
  78.     } /* if */
  79.     }};
  80. };
  81.  
  82. #endif
  83.  
  84.  
  85.